package com.eagle.spring.reactive.loader;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * 主线程串行执行
 */
public class FutureBlockingDataLoader extends DataLoader{
	protected void doLoad() {
		ExecutorService executorService = Executors.newFixedThreadPool(3); // 创建线程池
		runCompletely(executorService.submit(super::loadConfigurations));
		runCompletely(executorService.submit(super::loadUsers));
		runCompletely(executorService.submit(super::loadOrders));
		executorService.shutdown();
	}
	private void runCompletely(Future<?> future) {
		try {
			future.get();
		} catch (Exception e) {}
	}
}
